package com.yupi.oj.judge;

/**
 * @Author FengHuan Wang
 * @Date 2025/3/9 13:37
 * @Version 1.0
 */

import com.yupi.oj.judge.strategy.DefaultStrategy;
import com.yupi.oj.judge.strategy.JavaStrategy;
import com.yupi.oj.judge.strategy.JudgeContext;
import com.yupi.oj.judge.strategy.JudgeStrategy;
import com.yupi.oj.judge.codesanbox.model.JudgeInfo;
import com.yupi.oj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * 判题管理，简化调用
 */
@Service
public class JudgeManager {

    /**
     * 执行判题
     * @param judgeContext
     * @return
     */
    public JudgeInfo doJudge(JudgeContext judgeContext){
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultStrategy();
        if (language.equals("java")){
            judgeStrategy = new JavaStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
